package com.tengju.user.domain.model.login;

import com.tengju.user.domain.model.sms.OperationType;
import com.fasterxml.jackson.annotation.JsonCreator;
import com.fasterxml.jackson.annotation.JsonValue;
import lombok.AllArgsConstructor;

/**
 * @author wuziyang
 */
@AllArgsConstructor
public enum UserType {
    /**
     * 用户
     */
    USER(1,"用户"),
    /**
     * 员工
     */
    STAFF(2,"员工");

    private Integer val;
    private String desc;

    @JsonValue
    public Integer getVal() {
        return val;
    }

    public String getDesc() {
        return desc;
    }

    @JsonCreator
    public static UserType fromVal(Integer val) {
        for (UserType type : values()) {
            if (type.val.equals(val)) {
                return type;
            }
        }
        return null;
    }


    public static UserType fromName(String name) {
        for (UserType type : values()) {
            if (type.name().equals(name)) {
                return type;
            }
        }
        return null;
    }
}
